package com.finger.forest.adapter;

import android.content.Context;
import android.content.Intent;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.finger.forest.CollectionFireDetailActivity;
import com.finger.forest.R;
import com.finger.forest.model.CollectionRoadModel;
import com.finger.forest.model.FireInfoModel;

import java.util.List;

/**
 * @author jzj
 * @date 2021/1/27
 * @desc
 */
public class CollectionListFireAdapter extends BaseQuickAdapter<FireInfoModel, BaseViewHolder> {

    private static final String TAG = "CollectionListFireAdapter";

    private Context context;

    public CollectionListFireAdapter(int layoutResId, @Nullable List<FireInfoModel> data, Context context) {
        super(layoutResId, data);
        this.context = context;
    }

    @Override
    protected void convert(BaseViewHolder helper, FireInfoModel item) {
        helper.setText(R.id.tv_fire_name, item.getFirelocation());
        helper.setText(R.id.tvFireNum, item.getFirenumber());
        helper.setText(R.id.tvDistrict, item.getDistrict());
        String type = item.getFiresitetype();
        if (type.equals("1")){
            type = "耕地";
        } else if (type.equals("2")){
            type = "园地";
        } else if (type.equals("3")){
            type = "林地";
        } else{
            type = "草地";
        }
        helper.setText(R.id.tvFireType, type);

        //查看详情
        Button btn_fire_detail = helper.getView(R.id.btn_fire_detail);
        btn_fire_detail.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(context, CollectionFireDetailActivity.class);
                intent.putExtra("id",item.getId());
                context.startActivity(intent);
            }
        });
    }
}
